import $ from '../../../utils/ajax.js';
import util from '../../../utils/util.js';
const app = getApp();
Page({
    data: {
        isdata: '',
        types: '',
        title: '',
    },
    onLoad(options) {
        wx.setNavigationBarTitle({
            title: '更改' + options.name
        })
        this.setData({
            isdata: options.is,
            title: options.name,
            types: options.type,
            prime: options.prime
        })
    },
    cleans() {
        this.setData({
            isdata: ''
        })
    },
    onInput(e){
        this.setData({
            isdata: e.detail.value
        })
    },
    success() {
        const data = this.data;
        let prime = new Object;
        if (data.types === 'tel') {
            if (!util.telCheck(data.isdata, '')) return;
        } else if (data.types === 'text') {
            if (!util.nonEmpty(data.isdata,'请填写' + data.title)) return;
        }
        prime[data.prime] = data.isdata;
        $.p(app.wxApp.url + 'agentNew/editRoleInfo', prime, app.onStrart, (res) => {
            wx.navigateBack({ delta: 1 })
            app.onShop();
        }, (res) => {
            util.showTast(res.data)
        })
    }
})